package com.uyii.virtualthread.demos.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class VirtualThreadController {

    private final VirtualThreadService virtualThreadService;

    @Autowired
    public VirtualThreadController(VirtualThreadService virtualThreadService) {
        this.virtualThreadService = virtualThreadService;
    }

    @GetMapping("/startAsyncTasks")
    public String startAsyncTasks() {
        virtualThreadService.processAsyncTasks();
        return "异步任务已启动";
    }

}